/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    int findBottomLeftValue(TreeNode* root) {
        queue<TreeNode*> queue;
        int BottomLeftValue;

        queue.push(root);
        
        while(queue.empty() == false){
            int size = queue.size();
            TreeNode* node = queue.front();
            BottomLeftValue = node->val;
            
            for(int i = 0; i < size; ++i){
                node = queue.front();
                queue.pop();

                if(node->left) queue.push(node->left);
                if(node->right) queue.push(node->right);
            }
        }

        return BottomLeftValue;
    }
};